﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperWebSocket.SubProtocol;

namespace WebCommand.Command
{
    public class LOGIN : SubCommandBase<MySession>
    {
        public override void ExecuteCommand(MySession session, SubRequestInfo requestInfo)
        {
            lock (session.Server.SyncObj)
            {
                var temp = session.Server.GetSessionByUserName(requestInfo.Data);
                if (temp != null && temp != session)
                {
                    session.SendResponseAsync(string.Format("ERROR {0}", "该用户已登录"));
                    return;
                }
                session.UserName = requestInfo.Data;
                session.SendResponseAsync("LOGIN true");
            }
        }

    }
}
